
----测试
-- local preLuaSnapshot = nil

local function snapshotLuaMemory()
    
    local snapshot = require "snapshot"

	-- body
	print("GC前 lua内存是 ",collectgarbage("count"))

    local preLuaSnapshot = snapshot.snapshot()
    ---------------------
    
    local tal  = {1,"hello","dfdasfdsafdsafdsa"}
	
     local tal_test  = {1,"hello",2345}

	-------------------------
    print("GC 后 lua内存是 ",collectgarbage("count"))

	local curLuaSnapshot = snapshot.snapshot()
	local ret = {}
	local count = 0

	if preLuaSnapshot ~= nil then
		for k,v in pairs(curLuaSnapshot) do
			--print(k,v)
			if preLuaSnapshot[k] == nil then
				count = count + 1
				ret[k] = v
			end
		end
	end

	for k, v in pairs(ret) do
        print("k is ",k)
        print("v is ",v)
    end

    print ("Lua snapshot diff object count is " .. count)


    --preLuaSnapshot = curLuaSnapshot

end

--主入口函数。从这里开始lua逻辑
function Main()					
	print("logic start")	

	snapshotLuaMemory()
end

--场景切换通知
function OnLevelWasLoaded(level)
	collectgarbage("collect")
	Time.timeSinceLevelLoad = 0
end

function OnApplicationQuit()
end

